/*
 * Copyright 2020, GeoSolutions Sas.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 */

// **************
// Theme
// **************

#gn-components-theme(@theme-vars) {
    .gn-details-panel,
    .gn-details-panel > *,
    .gn-details-panel-header {
        .color-var(@theme-vars[main-color]);
        .background-color-var(@theme-vars[main-bg]);
    }

    .gn-details-panel-preview,
    .gn-details-panel-preview-loader {
        .color-var(@theme-vars[image-color]);
        .background-color-var(@theme-vars[image-bg]);
    }

    .gn-details-panel.loading .gn-details-panel-content {
        h1, a, p {
            color: transparent;
            .background-color-var(@theme-vars[placeholder-bg]);
        }
    }
    .gn-edit-toogle {
        .background-color-var(@theme-vars[placeholder-bg]);
    }

    .gn-details-panel {
        .gn-details-text {
            &.imagepreview {
                .icon-image-preview {
                    .color-var(@theme-vars[main-bg]);
                }
            }
        }
        .gn-resource-permissions-missing{
            .color-var(@theme-vars[danger]);
        }
        .gn-viewer-extent-map { 
            .gn-location-info {
                .bounds-row, .center-row {
                    .border-bottom-color-var(@theme-vars[main-border-color]);
                }
            }
            #gn-locations-map,
            #gn-locations-map .ol-viewport {
                .background-color-var(@theme-vars[main-variant-bg]);
            }
        }
    }
    .card-img-placeholder {
        .background-color-var(@theme-vars[main-bg]);
        .color-var(@theme-vars[primary]);
    }
    .gn-details-info-fields {
        .gn-details-info-row {
            .border-bottom-color-var(@theme-vars[main-border-color]);
            .gn-details-info-value {
                .gn-details-info-html {
                    .btn {
                        .border-bottom-color-var(@theme-vars[primary]);
                    }
                }
            }
        }
    }
    .gn-details-info {
        > .nav {
            .background-color-var(@theme-vars[main-bg]);
        }
    }
    .gn-details-panel-preview-wrapper {
        .border-color-var(@theme-vars[main-border-color]);
    }
}

// **************
// Layout
// **************

.gn-details-panel {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 10;
    section {
        .shadow();
        position: absolute;
        width: 100%;
        height: 100%;
        overflow-y: auto;
    }
    &.loading .gn-details-panel-content {
        h1,
        a,
        p {
            color: transparent;
        }
        a, .btn {
            display: none;
        }
    }

    .gn-details-text {
        flex: 1;
        [contenteditable], h1, h2, h3, h4, h5, h6 {
            padding: 0;
        }
        h1,
        h2,
        h3,
        h4,
        h5,
        h6 {
            margin-top: 0
        }
        .gn-details-text-input {
            border: none;
            font-size: 1.4rem;
            width: 100%;
            text-overflow: ellipsis;
            line-height: 1.4;
        }
        [contenteditable]:focus-visible, .gn-details-text-input {
            outline-color: @gn-editable-border;
        }
        &.imagepreview {
            z-index: 1;
            .icon-image-preview {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                font-size: 3em;
                opacity: 0.5;
                z-index: 0;
                pointer-events: none;
                .fa-file-upload{
                    padding-top: 2em;
                }

            }
        }

        &:last-of-type:not(.imagepreview):not(h1):not(h2):not(h3):not(h4):not(h5):not(h6) {
            padding-top: 0.3rem;
            font-size: 0.9rem;
        }
    }
    .gn-viewer-extent-map {
        height: 300px;
        position: relative;
        display: flex;
        width: 100%;
        .gn-location-info {
            font-size: @font-size-small;
            width: 250px;
            padding-right: 10px;
            .title, .bounds-row, .center-row {
                display: flex;
                justify-content: space-between;
            }
            .title {
                align-items: center;
                font-weight: lighter;
            }
            .bounds {
                padding-bottom: 4px;
            }
            .center {
                &.title {
                    padding-top: 5px;
                }
            }
            .bounds-row:last-child, .center-row:last-child {
                border-bottom: none;
            }
            .bounds-row, .center-row {
                padding: 4px 0;
                border-bottom-width: 1px;
                border-bottom-style: solid;
            }
        }
        .map-wrapper {
            position: relative;
            flex: 1;
            height: 100%;
            > span {
                font-weight: lighter;
                font-size: @font-size-small;
            }
        }
    }
}

.gn-details-panel-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    align-items: center;
    padding-left: 1rem;
    .fa + .gn-details-panel-header-title {
        margin-left: 0.5rem;
    }
    .gn-details-panel-header-title {
        flex: 1;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-weight: bold;
    }
}

.gn-details-panel-preview {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    &.inediting{
        padding-bottom:0
    }
}
.gn-details-panel-content-text {
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
    p:not(.gn-resource-status-text) {
        margin-left: 0.2rem;
        margin-bottom: 0;
    }

    p:nth-of-type(2) {
        margin-bottom: 0.3rem;
    }
}

.gn-details-panel-content {
    padding: 1rem;
    padding-top: 0;
    font-size: 0.9em;
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    .fa-edit, .fa-check-circle{
        font-size: 0.9rem;
        margin: 0.2em 0 0 0;
    }
}
.gn-details-panel-preview-wrapper {
    border: 1px solid transparent;
}
.gn-details-panel-content-img {
    margin: 0 1.2em 0 0;
    width: 250px;
    position: relative;
    img {
        position: relative;
        height: auto;
        object-fit: cover;
        width: 100%;
        height: 100%;
    }
    .card-img-placeholder,
    .gn-details-panel-preview,
    .ms-thumbnail,
    .imagepreview,
    .gn-detail-extent {
        position: relative;
        width: 100%;
        height: 100%;
    }
    .gn-details-panel-preview{
        .map-thumbnail{
            position: absolute;
            top: 10px;
            left: 45px;
            border-radius: 2px;
            z-index: 1;
            &.apply-button {
                opacity: 1;
                border-radius: 3px; 
            }
        }
        .gn-detail-extent {
            position: relative;
        }
        .gn-detail-extent-action { 
            position: absolute;
            top: 0;
            width: 100%;
            display: flex;
            justify-content: space-between;
            pointer-events: none;
            button {
                pointer-events: auto;
            }
            .btn {
                margin: 0.6rem;
            }
        } 
        .upload-thumbnail{
            position: absolute;
            top: 10px;
            left: 10px;
            border-radius: 2px;
        }
        .dropzone-content-image-added{
            width: 31px;
            height: 30px;
            position: absolute;
            top: 10px;
            left: 10px;
            z-index: 10;
            page-break-after: always;
            border-radius: 50px;
            background: transparent
        }
        .ms-thumbnail-dropzone{
            pointer-events: none;
        }

    }

}
.gn-details-panel-title {
    display: flex;
    align-items: center;
    h1 {
        display: flex;
        word-break: break-word;
        font-size: 1.4rem;
        margin: 0;
        margin-bottom: 0.2rem;
        .fa {
            margin: 0;
            margin-right: 0.6rem;
        }
    }

    .gn-details-panel-title-flex {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;

        div:first-of-type {
            flex: 1;
            display: flex;
            align-items: center;
        }

        .fa-info-circle {
            margin-right: 0;
            line-height: 1.5;
        }
    }

    .gn-details-panel-title-icon {
            margin-right: 0.6rem;
            margin-left: 0.2rem;
    }
    .gn-details-panel-tools{
        display: flex;
        justify-content: flex-end;
        align-items: center;
        button {
            margin: 4px;
        }
        .gn-unadvertised {
            padding: 0.25rem 0.5rem;
            font-size: 0.875rem;
            line-height: 1.5;
        }
    }
    .inEdit{
        align-items: center;
        display: flex;
    }
    .gn-details-text {
        h1.gn-details-text-body {
            line-height: 1.4;
            padding-top: 0;
            padding-bottom: 0;
        }
    }
}

.gn-details-panel-meta-text {

    div {
        * {
            font-size: 0.8rem;
        }
        span.gn-details-panel-origin {
            margin-right: 0.3rem;
        }
    }
}

.gn-details-panel-type {
    margin-top: 0.25rem;
}

.gn-details-panel-meta-date {
    margin-left: 0.25rem;
    font-size: 0.8rem;
}

.gn-details-panel-description {
    font-size: 0.9rem;
    text-align: justify;
    word-break: break-word;
    .gn-details-panel-text{
        margin-right: 0.5rem;
    }
    // force styles of html coming from WYSIWYG
    img {
        width: 100% !important;
        height: auto !important;
    }
    .gn-details-text,
    .gn-details-text-body {
        display: inline-block;
    }
}

.gn-details-thumbnail-loader {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.75);
    top: 0px;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    right: 0px;
}

.gn-details-info {
    padding: 1rem;
    > .nav {
        position: sticky;
        top: 40px;
        z-index: 1;
    }
    .tab-content {
        margin-top: 0.5rem;
        .linked-resources {
            > span {
                font-size: @font-size-small;
            }
        }
    }
}

.gn-details-info-fields {
    padding: 0.5rem 0;
    font-size: @font-size-small;
    position: relative;
    * {
        position: relative;
    }
    .gn-details-info-row {
        display: flex;
        border-bottom: 1px solid transparent;
        word-break: break-word;
        .gn-details-info-label {
            width: 250px; // similar to thumbnail
            padding: 0.25rem;
            font-weight: lighter;
        }
        .gn-details-info-value {
            padding: 0.25rem;
            flex: 1;
            padding-left: 1rem;
            max-width: calc(100% - 250px);
            .gn-details-info-html {
                &.collapsed {
                    display: flex;
                    width: 100%;
                    .gn-details-info-html-value {
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                    }
                }
                .btn {
                    padding: 0;
                    border: none;
                    border-bottom: 1px solid transparent;
                }
            }
            &> a {
                margin-right: 0.5rem;
                white-space: nowrap;
            }
        }
        &.linked-resources {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        &.link {
            border-bottom: none;
            .gn-details-info-label {
                padding: 0.25rem;
                font-weight: bold;
            }
        }
    }
    
}

.gn-details-info-table {
    padding: 0.5rem 0;
    font-size: @font-size-small;
    position: relative;
    * {
        position: relative;
    }
    .table {
        table-layout: fixed;
        tbody > tr {
            > th {
                padding: 0.25rem;
                font-weight: bold;
            }

            > td {
                padding: 0.25rem;
                font-weight: lighter;
                word-wrap: break-word;
            }

        }
    }
}

.gn-details-panel-content-img {
    > img,
    > .gn-details-panel-preview-wrapper {
        position: sticky;
        top: 40px;
    }
}

@media screen and (max-width: @screen-xs) {
    .gn-details-panel-title h1 {
        font-size: 1rem;
    }

    .gn-details-panel-content {
        display: block;
    }

    .gn-details-panel-content-img {
        width: 100%;
        margin: 0 0 1.2rem 0;
    }

    .gn-details-panel .gn-details-text.imagepreview {
        width: 100%;
    }
    .gn-details-info-fields {
        .gn-details-info-row {
            flex-direction: column;
            .gn-details-info-label {
                width: 100%;
            }
            .gn-details-info-value {
                padding-left: 0.25rem;
                font-size: @font-size-base;
                max-width: 100%;
            }
        }
    }
}

.gn-overlay-container {
    width: 100%;
}

.gn-overlay-wrapper {
    width: 800px
}

.gn-viewer-right-overlay {
    position: absolute;
    right: 0;
    height: 100%;
    z-index: 2000;
    transform: all 0.3s;
}

@media screen and (max-width: 800px) {
    .gn-overlay-wrapper {
        width: 100vw;
    }
}

.read-more-link {
    text-decoration: underline;
    cursor: pointer;
}